from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from OpenGL.GLE import *

angulos = [-45,-15,0]

#0: Mano
#1: Antebrazo
#2: Brazo

def init():
	glClearColor(0.0,0.8,0.6,0.9)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
	glColor3f(0.4,0.5,0.9) #color azul
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
	
	
def draw():
	glPushMatrix()
	glRotatef(15,1,0,0)
	glRotatef(-15,0,1,0)
	glScalef(0.3,0.3,0.3)
	glTranslatef(-2,0,0)
	#antebrazo()
	brazo()
	glPopMatrix()
	glFlush()
	glutSwapBuffers()	
	
def antebrazo():
	glPushMatrix()
	glRotatef(angulos[1],0,1,0)
	glPushMatrix()
	glTranslatef(1,0,0)
	glScalef(2,0.4,0.3)
	#glutSolidCube(1)
	glutWireCube(1)	
	glPopMatrix()
	glPushMatrix()
	glTranslatef(2,0,0)
	mano()
	glPopMatrix()
	glPopMatrix()
	return
	
	
def brazo():
	glPushMatrix()
	glRotatef(angulos[2],0,0,1)
	glPushMatrix()
	glColor3f(0.1,0.0,0.0)
	glTranslatef(1,0,0)
	glScalef(2,0.4,0.3)
	#glutSolidCube(1)
	glutWireCube(1)
	glPopMatrix()
	glTranslatef(2,0,0)
	antebrazo()
	glPopMatrix()
	return
	
	
def mano():
	global angulos
	glPushMatrix()
	glColor3f(0.5,0.9,0.1)
	glRotatef(angulos[0],0,1,0)
	glTranslatef(0.5,0.0,0.0)
	glScalef(1,0.5,0.3)
	glutWireCube(1)
	#glutSolidCube(1)
	glPopMatrix()
	return

		

if __name__ == '__main__':
	glutInit("mi brasito")
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
	glutInitWindowSize(500,500)
	glutInitWindowPosition(100,50)
	glutCreateWindow("mi brasito")
	init()
	glutDisplayFunc(draw)
	glEnable(GL_DEPTH_TEST)
	glDepthMask(GL_TRUE)
	glutMainLoop()

